package com.foxit.adapp;
import java.util.Random;

public class ActionUnit {   
     private String name;
     private String dimension;
     private String action;
     private String H;
     private String M;
     private String L;

     public ActionUnit() {
     }
     public ActionUnit(String gs) {
           if(gs != null && gs.length()!=0) {
              String[] g=gs.split(":");
              if(g.length==6) {
                 this.name = g[0];
                 this.dimension = g[1];
                 this.action = g[2];
                 this.H=g[3];
                 this.M=g[4];
                 this.L=g[5];
              }
           }
     }
     public ActionUnit(String name, String dimension, String action, String H, String M, String L) {
           this.name =name;
           this.dimension = dimension;
           this.action = action;
           this.H = H;
           this.M = M;
           this.L = L;
     }
     public String getADS(int v) { 
           switch(v) {
               case 3: return getH();
               case 2: return getM();
               case 1:
               default: return getL();
           }
     }
     public String getAD(int v) { 
           switch(v) {
               case 3: return getOneAD(H);
               case 2: return getOneAD(M);
               case 1:
               default: return getOneAD(L);
           }
     }
     public String getOneAD(String adl) {
           if(adl == null || adl.length()==0) return null;
           String[] a=adl.split(",");
           if(a.length > 1) {
               Random rand = new Random();
               int v = rand.nextInt(a.length);
               return a[v];
           }
           return adl;
     }

     public String getName() {
           return name;
     }
     public String getDimension() {
           return dimension;
     }
     public String getAction() {
           return action;
     }
     public String getH() {
           return H;
     }
     public String getM() {
           return M;
     }
     public String getL() {
          return L;
     }
}
